<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/12/21
 * Time: 16:09
 */

namespace app\crm\model;


use think\Db;

class GameTypeModel
{
    public static $table = 'game_type';

    public static function one($where = [])
    {
        $db = Db::name(self::$table);
        if (isset($where['name'])) {
            $db->where('name', $where['name']);
        }
        return $db->find();
    }

    public static function all()
    {
        return Db::name(self::$table)->order('add_time', 'desc')->select();
    }

    public static function lists($where = [], $page = 1, $pageSize = 10)
    {
        $db = Db::name(self::$table);
        return $db->page($page, $pageSize)->select();
    }

    public static function pagination($where = [], $pageSize)
    {
        $db = Db::name(self::$table);
        $db->order('add_time', 'desc');
        return $db->paginate($pageSize);
    }

    public static function insert($data)
    {
        return Db::name(self::$table)->insert($data);
    }
}